# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=usb-moded
pkgver=0.86.0
_pkgver=mer/$pkgver+mer40
pkgrel=0
pkgdesc="A daemon activating a certain USB profile based on the usb cable connection status"
url="https://git.sailfishos.org/mer-core/usb-moded"
arch="all"
license="GPL-2.0-only"
depends_dev="glib-dev dbus-glib-dev gobject-introspection-dev eudev-dev kmod-dev libdsme-dev elogind-dev ssu-sysinfo-dev sailfish-access-control"
makedepends="$depends_dev automake autoconf libtool dbus-dev"
subpackages="$pkgname-dev"
source="https://git.sailfishos.org/mer-core/usb-moded/-/archive/$_pkgver/usb-moded-${_pkgver/\//-}.tar.gz
	fix-musl-incompatibility.patch
	"
options="!check" # No test suite available
builddir="$srcdir/$pkgname-${_pkgver/\//-}"

prepare() {
	default_prepare

	# Fix invalid pkgconf version
	sed -i 's/+mer/./' configure.ac

	./autogen.sh
}

build() {
	./configure \
		--prefix=/usr \
		--enable-connman \
		--enable-ofono
	make
}

package() {
	DESTDIR="$pkgdir" make install

	# The pkg-config file isn't installed automatically for some reason
	install -dm 755 "$pkgdir"/usr/lib/pkgconfig
	install -m 644 usb_moded.pc "$pkgdir"/usr/lib/pkgconfig/

	install -dm 755 "$pkgdir"/usr/include/$pkgname
	cp src/*.h src/*.xml "$pkgdir"/usr/include/$pkgname
}

sha512sums="6c35a67fa7a44068af2fe942d9e828ae0456ed76e184c2fde57d319a6de4ab691de84c596f85f26770e30951972527c34204cb9221563bc9d84868042e0c6733  usb-moded-mer-0.86.0+mer40.tar.gz
504ce76ab1464b13a96fc69946d3b9bee45d91479786a9eb9bf82e893a22fd24c48bde71db789b769a4811069bde8003baf612594e35054b2da2865e9cb175ff  fix-musl-incompatibility.patch"
